interface client {
    [index: string]: any
}
export default class ClientController {
    private clients: client;
    constructor() {
        this.clients = new Array<client>();
    }
    public addClientWithId(id: string, obj: any):boolean {
        if(this.clients[id] != undefined) return false;

        this.clients[id] = obj;
        return true;
    }

    public removeClient(id: string, cb?: (obj: any)=> void): void {
        if(cb != undefined)  cb(this.clients[id]);

        this.clients[id] = undefined;
    }
    public getClient(id: string):any {
        return this.clients[id];
    }
    public foreach(cb: (id: string, obj: any) => void): void{
        for(let i in this.clients)
        {
            if(this.clients[i] != undefined)
            {
                cb(i, this.clients[i]);
            }
        }
    }
}